<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
<div id="app">
    <fieldset>
        <legend>用户登录</legend>
        用户名：<input type="text" v-model="tname"><br/>
        密码：<input type="password" v-model="password"><br/>
        <input type="button" value="登录" @click="login()">
    </fieldset>
</div>
<script src="js/vue.js"></script>
<script src="js/axios.js"></script>
</body>
<script>
    const app = Vue.createApp({
        data() {
            return {
                tname:"",
                password:""
            }
        },
        methods: {
            async login(){
                let {data:res} = await axios({
                    //post提交默认使用 json格式提交到后端
                    method:"post",
                    url:"tea/login",
                    data:{
                        tname:this.tname,
                        password:this.password
                    }
                })
                if(res==1){
                    location.href="findall.html"
                }else{
                    alert("用户名或密码错误")
                }
            }
        }
    })
    app.mount("#app")
</script>
</html>